package com.lynn.accesstoken;

import com.lynn.accesstoken.interceptor.AccessTokenInteceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@EnableCaching
@SpringBootApplication
public class AccesstokenApplication {

    public static void main(String[] args) {
        SpringApplication.run(AccesstokenApplication.class, args);
    }

    @Autowired
    private AccessTokenInteceptor accessTokenInteceptor;

    @Bean
    public WebMvcConfigurer webMvcConfigurer(){
        return new WebMvcConfigurer() {
            @Override
            public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(accessTokenInteceptor).addPathPatterns("/openApi/*");
            }
        };
    }

}
